//
//  LiveModule.m
//  NovelAPP
//
//  Created by BeatYourself on 2019/7/5.
//  Copyright © 2019 Facebook. All rights reserved.
//

#import "NAModule.h"
#import "AppDelegate.h"

@implementation NAModule

RCT_EXPORT_MODULE();

RCT_EXPORT_METHOD(loadVideoAd)
{
  dispatch_async(dispatch_get_main_queue(), ^{
    AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    [app.vc loadVideoAd];
  });
}

RCT_EXPORT_METHOD(setAdData:(NSDictionary*)adData)
{
//  NSMutableArray *ary = [NSMutableArray array];
  
  NSLog(@"unifiedInterstitialFailToLoadAd44%@",[NSString stringWithFormat:@"my dictionary is %@", adData]);
  
  dispatch_async(dispatch_get_main_queue(), ^{
    NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
    [userDefault setObject:adData forKey:@"adData"];
    
    AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    [app.vc handleShowAdData:adData];
    
    
  });

}

RCT_EXPORT_METHOD(setShowAdData:(NSDictionary*)adData)
{
//  NSMutableArray *ary = [NSMutableArray array];

  NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
  [userDefault setObject:adData forKey:@"showAdData"];

}

//RCT_EXPORT_METHOD(showAd:(BOOL)bl)
//{
//  dispatch_async(dispatch_get_main_queue(), ^{
//    AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication] delegate];
//    app.isShowAd = bl;
//    NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
//    [userDefault setBool:bl forKey:@"isShowAd"];
//
//  });
//}
//RCT_EXPORT_METHOD(isShowErrMsc:(BOOL)bl)
//{
//  dispatch_async(dispatch_get_main_queue(), ^{
//    AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication] delegate];
//    app.isShowAd = bl;
//    NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
//    [userDefault setBool:bl forKey:@"isShowErrMsc"];
//
//  });
//}

  @end
